game = 0;
document.write(game);
// canvas
var canvas = document.createElement("canvas"); 
var ctx = canvas.getContext("2d"); 
canvas.width = 800; 
canvas.height = 600; 
document.body.appendChild(canvas);
// global
var life = 3;
var score = 0;
var numAns = 0;
var level = 1;
var numQuest = 0;
// background
var bg = new Array();
for(var i='0';i<='9';i++)
{
	bg[i] = new Image();
	bg[i].src = "BG/game"+i+".png";
}
// protagonist
function Hero()
{
	var x = canvas.width/2;
	var y = canvas.height/2;
	var pic = new Array();
		this.pic[0] = new Image();
		this.pic[0].src = "character/hero_u.png";
		this.pic[1] = new Image();
		this.pic[1].src = "character/hero_d.png";
		this.pic[2] = new Image();
		this.pic[2].src = "character/hero_l.png";
		this.pic[3] = new Image();
		this.pic[3].src = "character/hero_r.png";
	function setXY(a,b)
	{
		x = a;
		y = b;
	}
}
// antagonist
function Enemy()
{
	var pic = new Image();
		this.pic = "character/enemy.png";
	var question = Array();
		question[0] = "";
		question[1] = "";
		question[2] = "";
		question[3] = "";
		question[4] = "";
		question[5] = "";
		question[6] = "";
		question[7] = "";
		question[8] = "";
		question[9] = "";
		question[10] = "";
		question[11] = "";
		question[12] = "";
		question[13] = "";
		question[14] = "";
		question[15] = "";
		question[16] = "";
		question[17] = "";
		question[18] = "";
		question[19] = "";
		question[20] = "";
		question[21] = "";
		question[22] = "";
		question[23] = "";
		question[24] = "";
		question[25] = "";
		question[26] = "";
		question[27] = "";
		question[28] = "";
		question[29] = "";
		question[30] = "";
		question[31] = "";
		question[32] = "";
		question[33] = "";
		question[34] = "";
		question[35] = "";
		question[36] = "";
		question[37] = "";
		question[38] = "";
		question[39] = "";
		question[40] = "";
		question[41] = "";
		question[42] = "";
		question[43] = "";
		question[44] = "";
		question[45] = "";
		question[46] = "";
		question[47] = "";
		question[48] = "";
		question[49] = "";
		question[50] = "";
		question[51] = "";
		question[52] = "";
		question[53] = "";
		question[54] = "";
		question[55] = "";
		question[56] = "";
		question[57] = "";
		question[58] = "";
		question[59] = "";
		question[60] = "";
		question[61] = "";
		question[62] = "";
		question[63] = "";
		question[64] = "";
		question[65] = "";
		question[66] = "";
		question[67] = "";
		question[68] = "";
		question[69] = "";
		question[70] = "";
		question[71] = "";
		question[72] = "";
		question[73] = "";
		question[74] = "";
		question[75] = "";
		question[76] = "";
		question[77] = "";
		question[78] = "";
		question[79] = "";
		question[80] = "";
		question[81] = "";
		question[82] = "";
		question[83] = "";
		question[84] = "";
		question[85] = "";
		question[86] = "";
		question[87] = "";
		question[88] = "";
		question[89] = "";
		question[90] = "";
		question[91] = "";
		question[92] = "";
		question[93] = "";
		question[94] = "";
		question[95] = "";
		question[96] = "";
		question[97] = "";
		question[98] = "";
		question[99] = "";
	var answer = new Array();
		answer[0] = "";
		answer[1] = "";
		answer[2] = "";
		answer[3] = "";
		answer[4] = "";
		answer[5] = "";
		answer[6] = "";
		answer[7] = "";
		answer[8] = "";
		answer[9] = "";
		answer[10] = "";
		answer[11] = "";
		answer[12] = "";
		answer[13] = "";
		answer[14] = "";
		answer[15] = "";
		answer[16] = "";
		answer[17] = "";
		answer[18] = "";
		answer[19] = "";
		answer[20] = "";
		answer[21] = "";
		answer[22] = "";
		answer[23] = "";
		answer[24] = "";
		answer[25] = "";
		answer[26] = "";
		answer[27] = "";
		answer[28] = "";
		answer[29] = "";
		answer[30] = "";
		answer[31] = "";
		answer[32] = "";
		answer[33] = "";
		answer[34] = "";
		answer[35] = "";
		answer[36] = "";
		answer[37] = "";
		answer[38] = "";
		answer[39] = "";
		answer[40] = "";
		answer[41] = "";
		answer[42] = "";
		answer[43] = "";
		answer[44] = "";
		answer[45] = "";
		answer[46] = "";
		answer[47] = "";
		answer[48] = "";
		answer[49] = "";
		answer[50] = "";
		answer[51] = "";
		answer[52] = "";
		answer[53] = "";
		answer[54] = "";
		answer[55] = "";
		answer[56] = "";
		answer[57] = "";
		answer[58] = "";
		answer[59] = "";
		answer[60] = "";
		answer[61] = "";
		answer[62] = "";
		answer[63] = "";
		answer[64] = "";
		answer[65] = "";
		answer[66] = "";
		answer[67] = "";
		answer[68] = "";
		answer[69] = "";
		answer[70] = "";
		answer[71] = "";
		answer[72] = "";
		answer[73] = "";
		answer[74] = "";
		answer[75] = "";
		answer[76] = "";
		answer[77] = "";
		answer[78] = "";
		answer[79] = "";
		answer[80] = "";
		answer[81] = "";
		answer[82] = "";
		answer[83] = "";
		answer[84] = "";
		answer[85] = "";
		answer[86] = "";
		answer[87] = "";
		answer[88] = "";
		answer[89] = "";
		answer[90] = "";
		answer[91] = "";
		answer[92] = "";
		answer[93] = "";
		answer[94] = "";
		answer[95] = "";
		answer[96] = "";
		answer[97] = "";
		answer[98] = "";
		answer[99] = "";
	function getQuest()
	{
		if(level==1)
		{
			numQuest = Math.random()*30;
		}
		else if(level==2)
		{
			do
			{
				numQuest = Math.random()*60;
			}while(numQuest<30);
		}
		else if(level==3)
		{
			do
			{
				numQuest = Math.random()*90;
			}while(numQuest<60);
		}
		else if(level==4)
		{
			do
			{
				numQuest = Math.random()*100;
			}while(numQuest<90);
		}
	}
	function check(ans)
	{
		if(ans==answer[numQuest])
		{
			numAns++;
			score += level*numAns;
		}
		else
		{
			life--;
		}
	}
}